Welcome![Sign In][Sign Up]
Location:
Search - 3D state

Search list

[Game ProgramACM国产凌凌发(008)系列3D游戏(MFC)

Description: “国产凌凌發(008)” 3D 系列游戏 本软件基于微软VC 6.0(MFC)为开发工具,运用了3D STATE最新的图形 引擎3D STATE engine API Version 6.0和声效引擎FireMOD(FMOD) 3.32。 具有艺术级的画面质量和动感的声音效果,能够设计出功能强大、娱乐性较 高的3D游戏来。同时本软件为开源软件,可到作者主页自由下载源代码。-"homemade Lingling made (008)," the 3D game software based on Microsoft VC 6.0 (MFC) development tools STATE use of the latest 3D graphics engine 3D engine API Version STATE engine 6.0 and costume FireMOD (FMOD) 3.32. With art picture quality and dynamic sound effects, to design powerful, high on entertainment 3D games. In addition, the software for open-source software can be downloaded free author Home source code.
Platform: | Size: 20350356 | Author: li | Hits:

[GDI-Bitmap汉诺塔的演示程序

Description: 初学MFC时的拙作,一个汉诺塔的演示程序,采用非递归、非堆栈的算法,直接根据当前步数推算出汉诺塔的状态。界面用GDI实现,伪3D的风格。-beginners at the exposition, a HANOR the demo program, the use of non - recursive and non-stack algorithm, directly under the current steps are projected HANOR state. GDI interface used to achieve, pseudo-3D style.
Platform: | Size: 13821 | Author: ioncannon | Hits:

[Dialog_Window3dbar_src

Description: 三维状态显示的对话框-3D state of the dialog box shows
Platform: | Size: 592000 | Author: 章景文 | Hits:

[Button control用C语言实现按钮新技术

Description: 按钮一般有按下和弹起两种状态,在3D studio中按钮也有这两种状态,Windows中虽然看到按钮虽是弹起的,但细心的用户不难发现,当选中按钮时,它有短暂的按下状态。实际上,它的原理很简单,其实是利用改变按钮边框的颜色引起人视觉上的错觉而达到立体效果,让人们感到屏幕上真有凸起和凹下的按钮一样,下载看一看。-general press the button and pop-up two states, which in 3D studio buttons have these two states, although the Windows button to see though is thrown up, but carefully users can easily find, elected to the central button, it is short of pressing state. Actually, it's very simple principle is actually changing the color of the button frame visually aroused people to achieve the illusion of three-dimensional effects, the people feel a great cosmopolitan screen uplift and subfoveal button, look at the download.
Platform: | Size: 3419 | Author: JK | Hits:

[Internet-Network用D3D模拟地月系

Description:

 

 

 

  一、建立空窗体

  新建一个工程,添加引用,并导入名称空间。

  加入一个设备对象变量:

private Microsoft.DirectX.Direct3D.Device device = null;

  添加初始化图形函数,并在这里面对设备对象进行实例化:

public void InitializeGraphics()
{
 PresentParameters presentParams = new PresentParameters();
 presentParams.Windowed = true;
 presentParams.SwapEffect = SwapEffect.Flip;
 presentParams.AutoDepthStencilFormat = DepthFormat.D16;
 presentParams.EnableAutoDepthStencil = true;
 device = new Microsoft.DirectX.Direct3D.Device(0, Microsoft.DirectX.Direct3D.DeviceType.Hardware, this,  CreateFlags.HardwareVertexProcessing, presentParams);
}

  当程序执行时,需要绘制场景,代码在这个函数里:

public void Render()

{
 // 清空设备,并准备显示下一帧。
 device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black , 1.0f, 0);
 // 设置照相机的位置
 SetupCamera();
 //开始场景
 device.BeginScene();
 if(meshLoaded)
 {
  mesh.Render(meshLoc);
 }
 device.EndScene();
 //显示设备内容。
 device.Present();
}

  设置照相机的位置:

private void SetupCamera()
{
 device.Transform.Projection = Matrix.PerspectiveFovLH((float)Math.PI / 4, this.Width / this.Height, 1.0f, 1000.00f);
 device.Transform.View = Matrix.LookAtLH(new Vector3(0.0f ,0.0f, 20.0f), new Vector3(0.0f,0.0f, 0.0f), new Vector3(0,1,0));
}

  现在改变主函数,调用我们写的初始化函数,并显示场景:

[STAThread]

static void Main()
{
 using (Form1 EarthForm = new Form1())
 {
  EarthForm.InitializeGraphics();
  EarthForm.Show();

  while(EarthForm.Created)
  {
   EarthForm.Render();
   Application.DoEvents();
  }
  EarthForm.Dispose();
}

  运行程序,会显示一个空的窗体。

  二、加入地球:

  在这一步里需创建一个3D网格对象,来作为要显示的地球,为此,在工程中新加入一个类Earth,此类可以包含所创建的网格对象的信息。

  加入一些相关变量,含义见注释:

public class Earth : BaseEarth
{
 private Material[] mMaterials; //保存材质
 private Texture[] mTextures; //保存纹理
 private Matrix locationOffset; //用来保存网格对象的相对位置
 private Mesh mMesh = null; //三角形网格对象
 private Device meshDevice; //需要显示在哪个设备上。
}

  在构造函数中,把Device设备拷贝到私有成员变量,这样就可以在这个类的其它方法内使用它,另外就是把位置变量进行赋值:

public Earth(ref Device device, Matrix location): base(ref device)
{
 meshDevice = device;
 locationOffset = location;
}

  下面这个函数是装入.X文件。

public bool LoadMesh(string meshfile)
{
 ExtendedMaterial[] mtrl;
 try
 {
  // 装载文件
  mMesh = Mesh.FromFile(meshfile, MeshFlags.Managed, meshDevice, out mtrl);
  // 如果有材质的话,装入它们
  if ((mtrl != null) && (mtrl.Length > 0))
  {
   mMaterials = new Material[mtrl.Length];
   mTextures = new Texture[mtrl.Length];

   // 得到材质和纹理

   for (int i = 0; i < mtrl.Length; i++)
   {
    mMaterials[i] = mtrl[i].Material3D;
    if ((mtrl[i].TextureFilename != null) && (mtrl[i].TextureFilename != string.Empty))

 

    {
     //前面得到的纹理的路径是相对路径,需要保存的是绝对路径,通过应用程序路径可以获得
     mTextures[i] = TextureLoader.FromFile(meshDevice, @"..\..\" + mtrl[i].TextureFilename);
    }
   }
  }
  return true;
 }
 catch
 {
  return false;
 }
}

  在这个方法内,使用Mesh.FromFile()这个方法,从给定的文件名中找到.X文件,并装入相关数据,一旦数据格式设置完成,可以从此文件中找到材质和贴图信息,并把它存放在数组中,并通过文件路径,得到纹理文件文件的路径,最后返回真值,如果整个过程出现错误,返回假值。

  下面这个Render()方法,是把此对象,即地球显示在设备对象上,此方法较简单,通过变形操作来得到网格对象的X,Y,Z坐标,接着设置网格对象的材质和纹理,最后,将每个材质和纹理应用到每个网格。

public void Render(Matrix worldTransform)
{
 /把位置变为世界坐标
 meshDevice.Transform.World = Matrix.Multiply(locationOffset, worldTransform);
 //绘制网格
 for (int i = 0; i < mMaterials.Length; i++)
 {
  meshDevice.Material = mMaterials[i];
  meshDevice.SetTexture(0, mTextures[i]);
  mMesh.DrawSubset(i);
 }
}

  现在回到窗体代码中,添加引用网格对象的相关变量:

private Earth mesh = null;
private Matrix meshLoc;
private bool meshLoaded = false;

  在图形初始化函数中,需要对网格对象进行初始化。加入下面的代码:

meshLoc = Matrix.Identity;
meshLoc.M41 = 2.0f;
mesh = new Earth(ref device, meshLoc);
if (mesh.LoadMesh(@"..\..\earth.x"))
{
 meshLoaded = true;
}

  代码第一句把网格对象的位置定为原点,接着偏移X轴2个单位,接下来从文件中得到此.X文件。如果成功设置,meshLoaded置为真。注意,这里有一个.X文件,在源代码中有此文件。

 


  在设置相机的函数中,加入一盏灯光:

device.Lights[0].Type = LightType.Directional;
device.Lights[0].Diffuse = Color.White;
device.Lights[0].Direction = new Vector3(0, -1, -1);
device.Lights[0].Update();
device.Lights[0].Enabled = true;


  此灯光较简单,仅为一个直射型白光灯。

最后,在Render()方法中,调用网格对象的Render()方法,以显示地球。

 

  三、使地球旋转

  前面用一个网格对象来建立地球,但此类没有平移,旋转及缩放等方法,下面就加入这些方法,因为这些方法具有通用性,因此可以新建一个类,把这些方法写在这些类中,使地球对象成为它的派生类。

  在工程中新添加一个类:BaseEarth;

  加入进行平移、旋转、缩放的变量:

 

private float xloc = 0.0f;
private float yloc = 0.0f;
private float zloc = 0.0f;
private float xrot = 0.0f;
private float yrot = 0.0f;
private float zrot = 0.0f;
private float xscale = 1.0f;
private float yscale = 1.0f;
private float zscale = 1.0f;


  加入相应的属性代码:

 

public float XLoc
{
 get
 {
  return xloc;
 }
 set
 {
  xloc = value;
 }
}
…………

 

  在Render()虚函数中,应用平移、旋转及缩放。
 

public virtual void Render()
{
 objdevice.MultiplyTransform(TransformType.World,Matrix.Translation(xloc, yloc, zloc));
 objdevice.MultiplyTransform(TransformType.World,Matrix.RotationAxis(new Vector3(1.0f, 0.0f, 0.0f), xrot));
 objdevice.MultiplyTransform(TransformType.World,Matrix.RotationAxis(new Vector3(0.0f, 1.0f, 0.0f), yrot));
 objdevice.MultiplyTransform(TransformType.World,Matrix.RotationAxis(new Vector3(0.0f, 0.0f, 1.0f), zrot));
 objdevice.MultiplyTransform(TransformType.World,Matrix.Scaling(xscale, yscale, zscale));
 return;
}

 

  现在回到地球类,需要将其改为新类的派生类,同时更改构造函数,另外,在Render()方法中,应先调用基类的Render()方法:


public override void Render()
{
 base.Render();
 //把位置变为世界坐标
 // meshDevice.Transform.World = Matrix.Multiply(locationOffset, worldTransform);
 //绘制网格
 。。。。。。
}

 


  现在,由于在基类中可以设置对象位置,因此,可以把与locationOffset相关,即与设置位置的变量及语句注释掉。

  四、加入月球

  在这一步加入月球,实际上是再创建一个网格对象新实例,只是把纹理进行更改即可,为了代码模块性更好,把两个对象放在一个新类CModel中,在工程中新添加一个类CModel,并声明对象实例。


public class cModel
{
 private cMeshObject mesh1 = null;
 private cMeshObject mesh2 = null;
 private bool modelloaded;
}


  把窗口代码中的Load()事件,放在CModel中,这次不仅生成了地球,而且生成了月球。

 


public void Load(ref Device device)
{
 mesh1 = new Earth(ref device);
 mesh2 = new Earth(ref device);
 if (mesh1.LoadMesh(@"..\..\earth2.x"))
 {
  modelloaded = true;
 }
 else
 {
  modelloaded = false;
 }
 if (mesh2.LoadMesh(@"..\..\moon.x"))
 {
  mesh2.XLoc += 20.0f;
  modelloaded = true;
 }
 else
 {
  modelloaded = false;
 }
}

 

  下面的Update()方法中,参数dir 用来判断是顺时针旋转还是逆时针旋转,另外,地球和月球绕Y轴增加的角度大小不同,也就决定了二者旋转的速度不同。


public void Update(int dir)
{
 if(dir > 0)
 {
  mesh1.YRot += 0.02f;
  mesh2.YRot += 0.05f;
 }
 else if(dir < 0)
 {
  mesh1.YRot -= 0.02f;
  mesh2.YRot -= 0.05f;
 }
}


  在下面的render()方法中,生成显示月球和地球:

 


public void Render(ref Device device)
{
 device.Transform.World = Matrix.Identity;
 if(modelloaded)
 {
  mesh1.Render();
  mesh2.Render();
 }
}


  把窗口代码中的加入灯光的方法,也放在此类中:


public void LoadLights(ref Device device)
{
 device.Lights[0].Type = LightType.Directional;
 device.Lights[0].Diffuse = Color.White;
 device.Lights[0].Position = new Vector3(0.0f, 0.0f, 25.0f);
 device.Lights[0].Direction = new Vector3(0, 0, -1);
}
public void Light(ref Device device)
{
 device.Lights[0].Update();
 device.Lights[0].Enabled = true;
}


  五、与鼠标交互操作

  为了实现与键盘、鼠标交互,新添加一个类:CMouse,添加引用Microsoft.DirectX.DirectInput,并添加命名空间。加入相关变量:


private Microsoft.DirectX.DirectInput.Device mouse = null;
public System.Threading.AutoResetEvent MouseUpdated;
private float x, y, z = 0.0f;
private byte[] buttons;

 

  在下面的构造函数代码中,首先创建鼠标设备,并初始化回调事件:


public CMouse(System.Windows.Forms.Control control)
{
 mouse = new Microsoft.DirectX.DirectInput.Device(SystemGuid.Mouse);
 mouse.SetCooperativeLevel(control, CooperativeLevelFlags.Background | CooperativeLevelFlags.NonExclusive);
 mouse.Properties.AxisModeAbsolute = false;
 MouseUpdated = new System.Threading.AutoResetEvent(false);
 mouse.SetEventNotification(MouseUpdated);
 mouse.Acquire();
 Update();

 


  下面的Update()方法中获得鼠标的坐标值,并赋给私有成员变量:

public void Update()
{
 MouseState state = mouse.CurrentMouseState;
 x = state.X;
 y = state.Y;
 z = state.Z;
 buttons = state.GetMouseButtons();
}


  还需要有一个函数来检测鼠标左键是否按下:

 


public bool LeftButtonDown
{
 get
 {
  bool a;
  return a = (buttons[0] != 0);
 }
}


  六、大结局

  现在已经做完了准备工作,返回到窗口代码中,需要对这里的代码重新进行一些调整:

  在图形初始化函数中创建一个CModel类及CMouse类:

 

private CModel model = null;
private CMouse mouse = null;
private bool leftbuttondown = false;
private float mousexloc;

 

  添加对鼠标初始化的方法:

 

网管联盟bitsCN@com


public void InitializeInput()
{
 mouse = new CMouse(this);
}


  添加UpdateInputState()方法,当按下鼠标左键时,将leftbuttondown值设置为真,当鼠标抬起时,将mousexloc置0:


private void UpdateInputState()
{
 mouse.Update();
 if (mouse.LeftButtonDown)
 {
  if(leftbuttondown == false)
  {
   mousexloc = 0.0f;
   leftbuttondown = true;
  }
  else
  {
   mousexloc = -mouse.X;
  }
 }
 else
 {
  leftbuttondown = false;
  mousexloc = 0.0f;
 }
}


  在此程序中,只对X值进行了操作,即只能左右转。

  Render()方法更新如下:

public void Render()
{
 UpdateInputState();
 device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.DarkGray, 1.0f, 0);
 SetupCamera();
 device.BeginScene();
 model.Update((int)mousexloc);
 model.Light(ref device);
 model.Render(ref device);
 device.EndScene();
 device.Present();
}

 

  最后更改Main()主函数:


static void Main()
{
 using (Form1 EarthForm = new Form1())
 {
  EarthForm.InitializeGraphics();
  EarthForm.InitializeInput();
  EarthForm.Show();
  while(EarthForm.Created)
  {
   EarthForm.Render();
   Application.DoEvents();
  }
  EarthForm.Dispose();
 }
 


Platform: | Size: 11817 | Author: mantoutou | Hits:

[Dialog_Window3dbar_src

Description: 三维状态显示的对话框-3D state of the dialog box shows
Platform: | Size: 591872 | Author: 章景文 | Hits:

[Button control用C语言实现按钮新技术

Description: 按钮一般有按下和弹起两种状态,在3D studio中按钮也有这两种状态,Windows中虽然看到按钮虽是弹起的,但细心的用户不难发现,当选中按钮时,它有短暂的按下状态。实际上,它的原理很简单,其实是利用改变按钮边框的颜色引起人视觉上的错觉而达到立体效果,让人们感到屏幕上真有凸起和凹下的按钮一样,下载看一看。-general press the button and pop-up two states, which in 3D studio buttons have these two states, although the Windows button to see though is thrown up, but carefully users can easily find, elected to the central button, it is short of pressing state. Actually, it's very simple principle is actually changing the color of the button frame visually aroused people to achieve the illusion of three-dimensional effects, the people feel a great cosmopolitan screen uplift and subfoveal button, look at the download.
Platform: | Size: 3072 | Author: | Hits:

[Game ProgramACM国产凌凌发(008)系列3D游戏(MFC)

Description: “国产凌凌發(008)” 3D 系列游戏 本软件基于微软VC 6.0(MFC)为开发工具,运用了3D STATE最新的图形 引擎3D STATE engine API Version 6.0和声效引擎FireMOD(FMOD) 3.32。 具有艺术级的画面质量和动感的声音效果,能够设计出功能强大、娱乐性较 高的3D游戏来。同时本软件为开源软件,可到作者主页自由下载源代码。-"homemade Lingling made (008)," the 3D game software based on Microsoft VC 6.0 (MFC) development tools STATE use of the latest 3D graphics engine 3D engine API Version STATE engine 6.0 and costume FireMOD (FMOD) 3.32. With art picture quality and dynamic sound effects, to design powerful, high on entertainment 3D games. In addition, the software for open-source software can be downloaded free author Home source code.
Platform: | Size: 20349952 | Author: li | Hits:

[GDI-BitmapHanoi_MFC_GDI

Description: 初学MFC时的拙作,一个汉诺塔的演示程序,采用非递归、非堆栈的算法,直接根据当前步数推算出汉诺塔的状态。界面用GDI实现,伪3D的风格。-beginners at the exposition, a HANOR the demo program, the use of non- recursive and non-stack algorithm, directly under the current steps are projected HANOR state. GDI interface used to achieve, pseudo-3D style.
Platform: | Size: 13312 | Author: ioncannon | Hits:

[Other Riddle games3D-Snake

Description: 使用openGL把原2D状态下的贪食蛇改进为3D状态,一开始可能会因不习惯而不容易上手-OpenGL using the original 2D state贪食蛇improve 3D state, the start may be unaccustomed to and not easy to use
Platform: | Size: 267264 | Author: Nicole | Hits:

[3D GraphicDownLoad

Description: 环境接口,应用于3D游戏开发。stdafx.h : 标准系统包含文件的包含文件。   Microsoft C 和 C++ 编译器提供了用于预编译任何 C 或 C++ 代码(包括内联代码)的选项。利用此性能特性,可以编译稳定的代码体,将已编译状态的代码存储在文件中,以及在随后的编译中,将预编译的代码与仍在开发的代码结合起来。由于不需要重新编译稳定代码,因此后面每次编译的速度都要快一些。 -Environment interface, used in 3D game development. stdafx.h: include file for standard system include files. Microsoft C and C++ Compiler provided for any pre-compiled C or C++ Code (including inline code) option. Using this performance characteristics, you can compile a stable body of code will be compiled state of the code stored in the document, as well as in subsequent compiler will pre-compiled code with the code still under development combine. Since the compiler does not need to re-stabilize the code, so the speed of the back of each compiler must faster.
Platform: | Size: 1369088 | Author: cui | Hits:

[OpenGL programArtificialLifeEvolutionSimulatorOpenGL3Dworldenvi

Description: Pretty cool 3D lower level AI simulator. There is a food chain. The low creatures eat the stationary food, the high creatures eat the low creatures. Once a pair mates , the mother carries eggs with her for a while. Once a counter is reached, the eggs hatch. This counter varries with genetics. When a pair mates, the child s DNA is composed of 40 mother s genes, 40 father s and 20 random. The genes contain information that controls the creatures behavior. This behavior works like Maslow s heirarchy of needs. There are 4 states, Look For Food, Look For Mate, Run Away, Roam Around. Genes contain a priority for each state. A creature will not do a priority 2 state if the requirements for priority 1 are not satisfied. These tolerances for these requirements are also contained in the genes.- Pretty cool 3D lower level AI simulator. There is a food chain. The low creatures eat the stationary food, the high creatures eat the low creatures. Once a pair mates , the mother carries eggs with her for a while. Once a counter is reached, the eggs hatch. This counter varries with genetics. When a pair mates, the child s DNA is composed of 40 mother s genes, 40 father s and 20 random. The genes contain information that controls the creatures behavior. This behavior works like Maslow s heirarchy of needs. There are 4 states, Look For Food, Look For Mate, Run Away, Roam Around. Genes contain a priority for each state. A creature will not do a priority 2 state if the requirements for priority 1 are not satisfied. These tolerances for these requirements are also contained in the genes.
Platform: | Size: 109568 | Author: anatolia | Hits:

[3D GraphicBH_Graph_SDK

Description: 北航虚拟现实国家重点实验室开发的3d图形引擎,这里是sdk-Beihang University, State Key Laboratory of Virtual Reality 3d graphics engine development, here is the sdk
Platform: | Size: 18012160 | Author: hanxiaoye | Hits:

[matlabBM3D

Description: The Block-Matching and 3D Filtering (BM3D) algorithm is a computationally scalable algorithm based on this novel denoising strategy. It achieves state-of-the-art denoising performance in terms of both peak signal-to-noise ratio and subjective visual quality.
Platform: | Size: 2906112 | Author: mythu | Hits:

[Menu controlVBcaidanclass

Description: 该源码为一个右键菜单类,实现了多种风格如WINDOW风格,XP风格,3D立体风格等状态的菜单表示图形。-The source code for a right-click menu class to achieve a variety of styles, such as WINDOW-style, XP style, 3D three-dimensional style, and the state, said graphical menu.
Platform: | Size: 29696 | Author: 胡晨 | Hits:

[Game Enginegame

Description: 游戏NPC人工智能情感系统的设计与实现,3D角色建模和有限状态技术-Games NPC AI system design and implementation of emotion, 3D character modeling and finite-state technology
Platform: | Size: 176128 | Author: 孙超 | Hits:

[matlabPAPER1

Description: This paper gives a comprehensive survey on 3D mesh watermarking, which is considered an effective solution to the above two emerging problems. Our survey covers an introduction to the relevant state of the art, Many researchers, from both the academic and the industrial sectors, have become aware of their intellectual property protection and authentication problems arising with their increasing use. In this paper we spacialy discus the advantages and disadvantages of the transformed domain methods and the spatial domain methods.
Platform: | Size: 232448 | Author: shishir | Hits:

[OpenGL programLorenz-Attractor-3D-OpenGL

Description: This program was created in Dev C++ (OpenGL). The Lorenz oscillator is a 3-dimensional dynamical system that exhibits chaotic flow, noted for its lemniscate shape. The map shows how the state of a dynamical system evolves over time in a complex, non-repeating pattern
Platform: | Size: 118784 | Author: space21 | Hits:

[Other Games3DState-Example1

Description: 3d state game engine example
Platform: | Size: 4348928 | Author: Biruk | Hits:

[Technology ManagementVC.3D

Description: VC编程中如何在界面上实现3D文字。 首先启动VC生成一个新的基于对话框的项目,命名为3Dtext,在对话框中重载OnPaint()函数,具体实现的思想是通过CDC::SetTextColor()分别设置文字的颜色为高亮(3DHILIGHT)和阴影(3DSHADOW)的状态下显示文字;同时注意在两次显示文字时要错开一个像素,这样才能达到预期的效果。-VC programming interface, the 3D text. The idea is to start the VC to generate a new dialog-based project, named 3Dtext override the OnPaint () function in the dialog box, the concrete realization by CDC :: SetTextColor () Set the font color for highlighting (3DHILIGHT state) and shadow (3DSHADOW,) to display text while paying attention to the display text twice to stagger one pixel, so as to achieve the desired results.
Platform: | Size: 3072 | Author: 龙共 | Hits:
« 12 »

CodeBus www.codebus.net